package com.future.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.future.common.annotation.ControllerMapping;
import com.future.common.annotation.NoNeedLogin;
import com.future.common.base.BaseController;
import com.future.common.bean.KV;
import com.future.dao.SysCodeDao;
import com.future.model.SysCode;
import com.jfinal.aop.Inject;
@ControllerMapping("/syscode")
public class SysCodeController extends BaseController {
	@Inject
	private SysCodeDao sysCodeDao;
	@NoNeedLogin
	public void getSysCodes() {
		List<SysCode> syscodes = this.sysCodeDao.findAllSyscode();
		HashMap<String, List<KV>> codes = new HashMap<String, List<KV>>();
		for(SysCode code:syscodes){
			if(codes.containsKey(code.getCodelx())){
				codes.get(code.getCodelx()).add(new KV(code.getCodedm(), code.getCodedesc()));
			}else{
				List<KV> codelist = new ArrayList<KV>();
				codelist.add(new KV(code.getCodedm(), code.getCodedesc()));
				codes.put(code.getCodelx(), codelist);
			}
		}
				
		renderResult("syscodes",codes);
		
	}
}
